package edu.jd.software.web.backend.config;

import com.github.pagehelper.PageInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;


@Configuration
@MapperScan({"edu.jd.software.web.backend.mbg.mapper","edu.jd.software.web.backend.dao"})
public class MyBatisConfig {
    @Bean
    public PageInterceptor pageInterceptor() {
        PageInterceptor pageInterceptor = new PageInterceptor();
        Properties properties = new Properties();
        properties.setProperty("helperDialect", "mysql"); // 设置数据库类型
        properties.setProperty("reasonable", "true"); // 启用合理化分页
        properties.setProperty("supportMethodsArguments", "true"); // 方法参数映射支持
        properties.setProperty("params", "count=countSql"); // 统计总行数SQL参数名
        pageInterceptor.setProperties(properties); // 设置属性值
        return pageInterceptor;
    }
}
